package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.DingVacationType;
import com.group.project.hrms.mapper.DingVacationTypeMapper;
import com.group.project.hrms.service.IDingVacationTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class DingVacationTypeService implements IDingVacationTypeService {

    @Autowired
    private DingVacationTypeMapper dingVacationTypeMapper;


    @Override
    public int insertDingVacationType(DingVacationType dingVacationType) {
        return dingVacationTypeMapper.insert(dingVacationType);
    }

    @Override
    public int deleteDingVacationType(DingVacationType dingVacationType) {
        return dingVacationTypeMapper.deleteByPrimaryKey(dingVacationType);
    }

    @Override
    public int updateDingVacationType(DingVacationType dingVacationType) {
        return dingVacationTypeMapper.updateByPrimaryKey(dingVacationType);
    }

    @Override
    public DingVacationType selectOneDingVacationType(DingVacationType dingVacationType) {
        Example example = new Example(DingVacationType.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("leaveCode", dingVacationType.getLeaveCode());
        return dingVacationTypeMapper.selectOneByExample(example);
    }

    @Override
    public List<DingVacationType> selectAllDingVacationType() {
        return dingVacationTypeMapper.selectAll();
    }
}
